package com.hh.servlet.showapply;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hh.dao.ShowDAO;

/**
 * Servlet implementation class ShowApply
 */
@WebServlet("/ShowApply")
public class ShowApply extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ShowApply() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setHeader("content-type", "text/html;charset=UTF-8");
		String vcode = request.getParameter("vcode");
		String shomobile = request.getParameter("shomobile");
		String hospital = request.getParameter("hospital");
		String connecter = request.getParameter("connecter");
		String conmobile = request.getParameter("conmobile");
		String shower = request.getParameter("shower");
		String code = (String) request.getSession().getAttribute(shomobile);
		if(code==null||vcode==null||!code.equals(vcode)){
			response.getWriter().print("您输入的验证码有误，请重新提交");
		}else{
			ShowDAO dao = new ShowDAO();
			dao.insertShow(hospital, connecter, conmobile, shower, shomobile, vcode);
			response.getWriter().print("申请成功");
			
		}
		
		
	}

}
